#define _CRT_SECURE_NO_WARNINGS 1

#include <stdio.h>
int main() 
{
	int n = 0, num1, num2, num3, price1, price2, price3, i = 0, j = 0, k = 0, count = 0;
	int price[10000] = { 0 };
	int min = 1000000;
	scanf("%d", &n);
	scanf("%d %d", &num1, &price1);
	scanf("%d %d", &num2, &price2);
	scanf("%d %d", &num3, &price3);
	for (i = 0; i <= n / num1 + 1; i++)
	{
		if (n <= num1 * i)
			price[count++] = i * price1;
	}
	for (j = 0; j <= n / num2 + 1; j++)
	{
		if (n <= num2 * j)
			price[count++] = j * price2;

	}
	for (k = 0; k <= n / num3 + 1; k++)
	{
		if ( n <= num3 * k)
		{
			price[count++] =  k * price3;
		}
	}
	min = price[0];
	for (i = 0; i < count; i++)
	{
		if (price[i] == 4)
		{
			break;
		}
		if (min > price[i])
			min = price[i];
	}

	printf("%d", min);
	return 0;
}
